package com.bt.dmdb.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.joda.time.LocalDateTime;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bt.dmdb.dao.LoginUsersDao;
import com.bt.dmdb.model.BusinessNature;
import com.bt.dmdb.model.Contact;
import com.bt.dmdb.model.CustomerDetails;
import com.bt.dmdb.model.CustomerDocument;
import com.bt.dmdb.model.CustomerQuestion;
import com.bt.dmdb.model.Document;
import com.bt.dmdb.model.DocumentDto;
import com.bt.dmdb.model.EagPassiveIncome;
import com.bt.dmdb.model.Locations;
import com.bt.dmdb.model.LoginUser;
import com.bt.dmdb.model.Market;
import com.bt.dmdb.model.MemberStatus;
import com.bt.dmdb.model.Question;
import com.bt.dmdb.model.Regulators;
import com.bt.dmdb.model.RestrictedDistributor;
import com.bt.dmdb.model.SourceIncome;
import com.bt.dmdb.model.StocksDistribution;
import com.bt.dmdb.service.UsersService;

@Service("usersService")
@Transactional(value = "txmDmdb")
public class UsersServiceImpl implements UsersService {

    @Resource
    private LoginUsersDao usersDao;

    public LoginUsersDao getUsersDao() {
        return usersDao;
    }

    public void setUsersDao(LoginUsersDao usersDao) {
        this.usersDao = usersDao;
    }

    @Override
    public LoginUser getLoggedInUser(Long userId) {
        return usersDao.getLoggedInUser(userId);        
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public LoginUser getUser(String login) {
    	return usersDao.getUser(login);
    	
    }
    
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerQuestion> getResponseNFFE(long id) {
        return usersDao.getResponseNFFE(id);
    }
    
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerQuestion> getResponseFFI(long id) {
        return usersDao.getResponseFFI(id);
    }
    
    @Transactional(value = "txmDmdb", readOnly = true)
    public LoginUser validateUser(String userName, String password) {
        return usersDao.validateUser(userName, password);
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<LoginUser> findAllUsers() {
        return usersDao.findAllUsers();
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public List<LoginUser> findAllCheckers() {
    	return usersDao.findAllCheckers();
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public List<Question> findQuesByCategory(String category) {
    	return usersDao.findQuesByCategory(category);
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public void addUser(String firstName, String lastName, String emailId, String password,String role) {
    	usersDao.addUser(firstName, lastName, emailId, password, role);
    	return;
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public void editUser(Long id, String firstName, String lastName, String emailId, String password,String role) {
    	usersDao.editUser(id, firstName, lastName, emailId, password, role);
    	return;
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public LoginUser findUserById(long id) {
    	return usersDao.findUserById(id);
    	
    }
    
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public CustomerDetails addCustomerDetails(CustomerDetails details, LoginUser loginUser) {
    	 return usersDao.addCustomerDetails(details, loginUser);
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerDetails> findAllCustomers() {
        return usersDao.findAllCustomers();
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerDetails> getAllCustomers() {
        return usersDao.getAllCustomers();
    }
    
    
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerDetails> findAllCustomersChecker() {
        return usersDao.findAllCustomersChecker();
    }
    
    
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public CustomerDetails findCustomerById(long id) {
    	return usersDao.findCustomerById(id);
    	
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public void deleteUserById(long id) {
    	usersDao.deleteUserById(id);
    	
    }
    
//     @Override
//    @Transactional(value = "txmDmdb", readOnly = false)
//    public void saveDocs(Blob doc) {
//    	 usersDao.saveDocs(doc);
//    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public void saveDocs(Long custID, Long docId, String fileName,LocalDateTime localDateTime,String filePath) {
    	 usersDao.saveDocs(custID, docId, fileName, localDateTime,filePath);
    }
     
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<Document> getDocuments() {
        return usersDao.getDocuments();
    }
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<Document> getDocuments1() {
        return usersDao.getDocuments1();
    }
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerDocument> findDocumentByCustId(long id) {
        return usersDao.findDocumentByCustId(id);
    }
    
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<Question> findNFFECommonQuestion(){
        return usersDao.findNFFECommonQuestion();
    }
    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public Map<Object, Object> findMakerInitialQuestion(){
    	 return usersDao.findMakerInitialQuestion();
    }

    @Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<Document> getDocumentNames() {
        return usersDao.getDocumentNames();
    }
    @Override
    @Transactional(value = "txmDmdb", readOnly = false)
    public Object[] saveMakerInitialQuest(String custID, String catL, String quesId0, String ansId0, String quesId1, String ansId1, String catdd) {
      return usersDao.saveMakerInitialQuest(custID, catL, quesId0, ansId0, quesId1, ansId1, catdd);
    }

	@Override
	public List<Object> getListOfFFICategory() {
		 return usersDao.getListOfFFICategory();
	}

	@Override
	public List<Object> getListOfNFFECategory() {
		// TODO Auto-generated method stub
		 return usersDao.getListOfNFFECategory();
	}

	@Override
	public Map<Long, DocumentDto> getRules() {
		return usersDao.getRules();
	}

	@Override
	public List<Document> findDocumentRules() {
		// TODO Auto-generated method stub
		return usersDao.findDocumentRules();
	}

	@Override
	public List<CustomerQuestion> getResponseSpecNFFE(long id) {
		// TODO Auto-generated method stub
		return usersDao.getResponseSpecNFFE(id);
	}

	@Override
	public List<CustomerQuestion> getResponseSpecFFI(long id) {
		// TODO Auto-generated method stub
		return usersDao.getResponseSpecFFI(id);
	}
	@Override
	public List<CustomerDocument> documentUploded(long id) {
		// TODO Auto-generated method stub
		return usersDao.documentUploded(id);
	}
	

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
    public void saveDocumentRulesByDocId(DocumentDto y) {
        usersDao.saveDocumentRulesByDocId(y);
    }
	
	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
    public void deleteByCustomerId(CustomerDocument y) {
        usersDao.deleteByCustomerId(y);
    }
	
	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
    public void deleteAdminByDocumentId(Document y) {
        usersDao.deleteAdminByDocumentId(y);
    }
	
	@Override
	public List<DocumentDto> getAdminDocRules() {
		return usersDao.getAdminDocRules();
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllUsers(List<LoginUser> y) {
		 usersDao.saveAllUsers(y);
		
	}
	
	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllBusinessNature(List<BusinessNature> y) {
		 usersDao.saveAllBusinessNature(y);
		
	}
	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllEagMemberStatus(List<MemberStatus> y)
	{
		usersDao.saveAllEagMemberStatus(y);
	}
	
	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllPassiveIncome(List<EagPassiveIncome> y)
	{
		usersDao.saveAllPassiveIncome(y);
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllExchangeMarket(List<Market> y) {
		usersDao.saveAllExchangeMarket(y);
		
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllLocation(List<Locations> y) {
		
		usersDao.saveAllLocation(y);
		
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllRegulators(List<Regulators> y) {
		
		usersDao.saveAllRegulators(y);
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllRestrictedDistributor(List<RestrictedDistributor> y) {
		usersDao.saveAllRestrictedDistributor(y);
		
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllStocksDistribution(List<StocksDistribution> y) {
	
		usersDao.saveAllStocksDistribution(y);
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllSourceIncome(List<SourceIncome> y) {
	
		usersDao.saveAllSourceIncome(y);
	}

	@Override
	@Transactional(value = "txmDmdb", readOnly = false)
	public void saveAllContact(List<Contact> y) {

		usersDao.saveAllContact(y);
	}
	
	@Override
    @Transactional(value = "txmDmdb", readOnly = true)
    public List<CustomerDetails> getAllAuditor() {
        return usersDao.getAllAuditor();
    }
	
	
}
